home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / Examples / Draw / Include / DrawPart.h < prev    next >
Encoding:
Text File  |  1994-04-21  |  8.5 KB  |  276 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                DrawPart.h
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Author:                Henri Lamiraux
  7. //    Creation Date:        3/28/94
  8. //
  9. //    Copyright:    © 1993, 1994 by Apple Computer, Inc., all rights reserved.
  10. //
  11. //========================================================================================
  12.  
  13. #ifndef DRAWPART_H
  14. #define DRAWPART_H
  15.  
  16. #ifndef DRAWDEF_H
  17. #include "DrawDef.h"
  18. #endif
  19.  
  20. // ----- Framework Includes -----
  21.  
  22. #ifndef FWPARTING_H
  23. #include "FWParting.h"
  24. #endif
  25.  
  26. // ----- OPF Foundation Includes -----
  27.  
  28. #ifndef BCCOLLU_H
  29. #include <BCCollU.h>
  30. #endif
  31.  
  32. // ----- Graphic Includes -----
  33.  
  34. #ifndef FWCOLOR_H
  35. #include <FWColor.h>
  36. #endif
  37.  
  38. //==============================================================================
  39. //    •• Forward Declarations
  40. //==============================================================================
  41.  
  42. class CDrawSelection;
  43. class CBaseShape;
  44. class FW_CFloatingWindow;
  45. class CLink;
  46. class CProxyShape;
  47. class CPaletteFacet;
  48. class CToolFacet;
  49. class BC_CUnmanaged;
  50.  
  51. //==============================================================================
  52. //    •• Constants
  53. //==============================================================================
  54.  
  55. const short kArrangeMenu = 4;
  56. const short kPenSizeMenu = kArrangeMenu + 1;
  57. const short kWindowMenu = kPenSizeMenu + 1;
  58.  
  59. // ----- Commands -----
  60. const XMPCommandID cMoveForward        = 1;
  61. const XMPCommandID cMoveToFront        = cMoveForward + 1;
  62. const XMPCommandID cMoveBackward    = cMoveToFront + 1;
  63. const XMPCommandID cMoveToBack         = cMoveBackward + 1;
  64. const XMPCommandID cFreeze             = cMoveToBack + 1;
  65. const XMPCommandID cDefrost         = cFreeze + 1;
  66.  
  67. const XMPCommandID cPen1         = cDefrost + 1;
  68. const XMPCommandID cPen2         = cPen1+1;
  69. const XMPCommandID cPen3         = cPen2+1;
  70. const XMPCommandID cPen4         = cPen3+1;
  71. const XMPCommandID cPen5         = cPen4+1;
  72.  
  73. const XMPCommandID cHideShowTools = cPen5+1;
  74. const XMPCommandID cHideShowPalette = cHideShowTools+1;
  75.  
  76. const unsigned short kToolWidth = 43;
  77. const unsigned short kToolHeight = 64;
  78. const unsigned short kSelectorHeight = 12;
  79. const unsigned short kColorSelectorWidth = 37;
  80. const unsigned short kColorSelectorHeight = 30;
  81. const unsigned short kToolsWindowWidth = 2 + kToolWidth + 2;
  82. const unsigned short kToolsWindowHeight = 2 + kToolHeight + 4 + kSelectorHeight + 8 + kColorSelectorHeight + 5;
  83.  
  84. const unsigned short kPaletteWindowWidth = 2 + 32 * 9 + 1 + 2;
  85. const unsigned short kPaletteWindowHeight = 2 + 8 * 9 + 1 + 2;
  86.  
  87. const unsigned short kSelectTool = 1;
  88. const unsigned short kLine = 2; 
  89. const unsigned short kRectangle = 3; 
  90. const unsigned short kOval = 4; 
  91. const unsigned short kRoundRect = 5;
  92. const unsigned short kArc = 6;
  93.  
  94. //==============================================================================
  95. //    •• class CDrawPart
  96. //==============================================================================
  97.  
  98. class CDrawPart : public FW_CEmbeddingPart
  99. {
  100. //------------------------------------------------------------------------------
  101. //    • Initialization/Destruction
  102. //
  103. public:        
  104.     CDrawPart();
  105.     virtual ~ CDECL CDrawPart();
  106.  
  107.     virtual void            Initialize();
  108.     virtual void            AddProperties(XMPStorageUnit* storageUnit);
  109.     virtual void            Release();
  110.     
  111.     virtual XMPValueType     GetContentPropertyValueType() const; 
  112.  
  113. //------------------------------------------------------------------------------
  114. //    • Inherited API
  115. //
  116. public:
  117.     virtual FW_CFrame*         NewFrame(XMPFrame* xmpFrame, XMPTypeToken presentation);
  118.                                     
  119.     virtual void             ExternalizeContent(XMPStorageUnit* storageUnit);
  120.     virtual void             InternalizeContent(XMPStorageUnit* storageUnit);
  121.  
  122.     virtual FW_Boolean        DoMenuEvent(XMPMenuBar *menuBar, XMPCommandID commandID);
  123.     virtual void            DoAdjustMenus(XMPMenuBar* menuBar);
  124.     
  125.     virtual FW_CProxyRun*        NewProxyRun();
  126.     
  127.     virtual XMPTypeToken    GetDefaultPresentation() const;
  128.     
  129. //------------------------------------------------------------------------------
  130. //    • New API
  131. //
  132. public:    
  133.     CProxyShape*            NewProxyShape(XMPPart* xmpPart, const FW_CRect& shapeRect, FW_Boolean invalidate);
  134.  
  135.     void                    DeleteShape(CBaseShape* shape);
  136.     void                    AddShape(CBaseShape* shape);
  137.     void                    AddShapeAfter(CBaseShape* after, CBaseShape* shape);
  138.  
  139.     BC_TUnboundedCollection<CBaseShape*, BC_CUnmanaged>*    GetShapeList() const;
  140.     XMPCoordinate            GetPenSize() const;
  141.     unsigned short                GetFillFrame() const;
  142.  
  143.     void                    CheckTool(unsigned short oldTool, unsigned short newTool);
  144.     void                    CheckFillFrame(unsigned short oldFillFrame, unsigned short newFillFrame);
  145.     void                    SetFillFrame(unsigned short fillFrame);
  146.     
  147.     void                    GetFillColor(FW_CColor* color) const;
  148.     void                    GetPenColor(FW_CColor* color) const;
  149.  
  150.     void                    SetFillColor(const FW_CColor& color);
  151.     void                    SetPenColor(const FW_CColor& color);
  152.     
  153.     void                    MoveForward();
  154.     void                    MoveBackward();
  155.     void                    MoveToFront();
  156.     void                    MoveToBack();
  157.  
  158.     void                    SetTool(unsigned short newTool);
  159.     unsigned short                GetTool() const;
  160.                                 
  161.     virtual FW_CSelection*    NewSelection();
  162.     
  163.     XMPTypeToken            GetMainPresentation() const;
  164.     XMPTypeToken            GetPalettePresentation() const;
  165.     XMPTypeToken            GetToolPresentation() const;
  166.  
  167.     CBaseShape*                NewShape(unsigned short shapeType);
  168.     
  169. private:
  170.     BC_TUnboundedCollection<CBaseShape*, BC_CUnmanaged>*        ExtractSelection();
  171.  
  172. //------------------------------------------------------------------------------
  173. //    • Data Members
  174. //------------------------------------------------------------------------------
  175. private:    
  176.     MenuHandle            fArrangeMenu;
  177.     MenuHandle            fPenSizeMenu;
  178.     MenuHandle            fWindowMenu;
  179.     
  180.     FW_CFloatingWindow*    fPaletteWindow;
  181.     FW_CFloatingWindow*    fToolsWindow;
  182.     
  183.     BC_TUnboundedCollection<CBaseShape*, BC_CUnmanaged>*    fShapeList;
  184.     unsigned short            fTool;
  185.     XMPCoordinate        fCurrentPenSize;
  186.     unsigned short            fFillFrame;
  187.     FW_CColor            fFillColor;
  188.     FW_CColor            fPenColor;
  189.     
  190.     unsigned short            fNbEmbedded;
  191.  
  192.     XMPTypeToken        fPalettePresentation;
  193.     XMPTypeToken        fToolPresentation;
  194.     XMPTypeToken        fMainPresentation;
  195.     
  196.     CDrawSelection*        fDrawSelection;
  197. };
  198.  
  199. //==============================================================================
  200. //    •• Inlines
  201. //==============================================================================
  202.  
  203. //------------------------------------------------------------------------------
  204. //    • CDrawPart::GetShapeList
  205. //------------------------------------------------------------------------------
  206. inline BC_TUnboundedCollection<CBaseShape*, BC_CUnmanaged>* CDrawPart::GetShapeList() const
  207. {
  208.     return fShapeList;
  209. }
  210.  
  211. //------------------------------------------------------------------------------
  212. //    • CDrawPart::GetPenSize
  213. //------------------------------------------------------------------------------
  214. inline XMPCoordinate CDrawPart::GetPenSize() const
  215. {
  216.     return fCurrentPenSize;
  217. }
  218.  
  219. //------------------------------------------------------------------------------
  220. //    • CDrawPart::GetFillFrame
  221. //------------------------------------------------------------------------------
  222. inline unsigned short CDrawPart::GetFillFrame() const
  223. {
  224.     return fFillFrame;
  225. }
  226.  
  227. //------------------------------------------------------------------------------
  228. //    • CDrawPart::GetTool
  229. //------------------------------------------------------------------------------
  230. inline unsigned short CDrawPart::GetTool() const
  231. {
  232.     return fTool;
  233. }
  234.  
  235. //------------------------------------------------------------------------------
  236. //    • CDrawPart::GetMainPresentation
  237. //------------------------------------------------------------------------------
  238. inline XMPTypeToken CDrawPart::GetMainPresentation() const
  239. {
  240.     return fMainPresentation;
  241. }
  242.  
  243. //------------------------------------------------------------------------------
  244. //    • CDrawPart::GetPalettePresentation
  245. //------------------------------------------------------------------------------
  246. inline XMPTypeToken CDrawPart::GetPalettePresentation() const
  247. {
  248.     return fPalettePresentation;
  249. }
  250.  
  251. //------------------------------------------------------------------------------
  252. //    • CDrawPart::GetToolPresentation
  253. //------------------------------------------------------------------------------
  254. inline XMPTypeToken CDrawPart::GetToolPresentation() const
  255. {
  256.     return fToolPresentation;
  257. }
  258.  
  259. //------------------------------------------------------------------------------
  260. //    • CDrawPart::GetFillColor
  261. //------------------------------------------------------------------------------
  262. inline void CDrawPart::GetFillColor(FW_CColor* color) const
  263. {
  264.     *color = fFillColor;
  265. }
  266.  
  267. //------------------------------------------------------------------------------
  268. //    • CDrawPart::GetPenColor
  269. //------------------------------------------------------------------------------
  270. inline void CDrawPart::GetPenColor(FW_CColor* color) const
  271. {
  272.     *color = fPenColor;
  273. }
  274.  
  275. #endif
  276.